package project.model;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import project.dao.EmployeeDAO;
import model.pojo.Employee;
import models.util.UtilInitLang;

public class PrLogChange implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2605515934215456730L;

	private String idLogChange;
	private String idTest;
	private String idEmployee;
	private Date timeEdit;
	private Employee employee;
	private String dateDisplay;
	private int status;
	private String titleChange;
	private String contentChange;
	private String strStatus;
	DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm aaa");
	private String colorText;
	private String db=null;
	
	
	public String getDb() {
		return db;
	}

	public void setDb(String db) {
		this.db = db;
	}

	public PrLogChange(String idLogChange, String idTest, String idEmployee, Date timeEdit,
			int status, String titleChange, String contentChange) {
		this.idLogChange = idLogChange;
		this.idTest = idTest;
		this.idEmployee = idEmployee;
		this.timeEdit = timeEdit;
		this.status = status;
		this.titleChange = titleChange;
		this.contentChange = contentChange;
		int index = titleChange.indexOf("-%$#@!-");
		if(index > 0){
			this.titleChange = titleChange.substring(0,index);
			this.colorText = titleChange.substring(index + 7, titleChange.length());
		}else{
			this.titleChange = titleChange;
			this.colorText = "";
		}	
	}
	
	public String getIdLogChange() {
		return idLogChange;
	}
	public void setIdLogChange(String idLogChange) {
		this.idLogChange = idLogChange;
	}
	public String getIdTest() {
		return idTest;
	}
	public void setIdTest(String idTest) {
		this.idTest = idTest;
	}
	public String getIdEmployee() {
		return idEmployee;
	}
	public void setIdEmployee(String idEmployee) {
		this.idEmployee = idEmployee;
	}
	public Date getTimeEdit() {
		return timeEdit;
	}
	public void setTimeEdit(Date timeEdit) {
		this.timeEdit = timeEdit;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public Employee getEmployee() {
		if(db!=null){
			EmployeeDAO edao = new EmployeeDAO();
			employee = edao.getOneEmployee(idEmployee,db);
		}		
		return employee;
	}

	public void setDateDisplay(String dateDisplay) {
		this.dateDisplay = dateDisplay;
	}

	public String getDateDisplay() {
		if(timeEdit != null){
			dateDisplay = format.format(timeEdit);
		}
		return dateDisplay;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getTitleChange() {
		return titleChange;
	}

	public void setTitleChange(String titleChange) {
		this.titleChange = titleChange;
	}

	public String getContentChange() {
		return contentChange;
	}

	public void setContentChange(String contentChange) {
		this.contentChange = contentChange;
	}

	public String getStrStatus() {
		UtilInitLang lang = new UtilInitLang();
		if(status == 0){
			strStatus = lang.getValue("st_addnew");
		} else {
			strStatus = lang.getValue("Edit");
		}
		return strStatus;
	}

	public void setStrStatus(String strStatus) {
		this.strStatus = strStatus;
	}

	public void setColorText(String colorText) {
		this.colorText = colorText;
	}

	public String getColorText() {
		return colorText;
	}
	
}
